// 定义颜色变量
@primary: #1EB7D8;
@secondary1: #D4E9FC;
@secondary2: #ECFFF9;
@darkText: #0A6E8A;
@light: #FAFCFF;
@kb1: #FF9E7D;
@kb2: #8CD790;
@kb3: #FFD966;
@kb4: #A7ACEF;
@success: #4CAF50;
@error: #FF5252;
@game: #FF6B8B;

// 定义字体
@font-family: 'Comic Sans MS', 'Comic Neue', 'Marker Felt', 'Arial Rounded MT Bold', sans-serif;

// 重置和基础样式
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: @font-family;
  background-color: @light;
  overflow-x: hidden;
}

#root {
  min-height: 100vh;
}

// 布局工具类
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem;
  
  @media (max-width: 480px) {
    padding: 0 0.5rem;
  }
}

.min-h-screen {
  min-height: 100vh;
}

.relative {
  position: relative;
}

.fixed {
  position: fixed;
}

.absolute {
  position: absolute;
}

.block {
  display: block;
}

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.my-auto {
  margin-top: auto;
  margin-bottom: auto;
}

// 间距工具类
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-10 { margin-top: 2.5rem; }
.mt-12 { margin-top: 3rem; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

// .mr-2 { margin-right: 0.5rem; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.px-4 { 
  padding-left: 1rem; 
  padding-right: 1rem; 
}

.px-10 { 
  padding-left: 2.5rem; 
  padding-right: 2.5rem; 
}

.px-12 { 
  padding-left: 3rem; 
  padding-right: 3rem; 
}

.py-2 { 
  padding-top: 0.5rem; 
  padding-bottom: 0.5rem; 
}

.py-3 { 
  padding-top: 0.75rem; 
  padding-bottom: 0.75rem; 
}

.py-4 { 
  padding-top: 1rem; 
  padding-bottom: 1rem; 
}

.py-6 { 
  padding-top: 1.5rem; 
  padding-bottom: 1.5rem; 
}

// 尺寸工具类
.w-6 { width: 1.5rem; }
.w-7 { width: 1.75rem; }
.w-8 { width: 2rem; }
.w-9 { width: 2.25rem; }
.w-10 { width: 2rem; }
.w-24 { width: 6rem; }
.w-28 { width: 7rem; }
.w-32 { width: 8rem; }
.w-36 { width: 9rem; }

.h-6 { height: 1.5rem; }
.h-7 { height: 1.75rem; }
.h-8 { height: 2rem; }
.h-9 { height: 2.25rem; }
.h-10 { height: 2rem; }
.h-24 { height: 6rem; }
.h-28 { height: 7rem; }
.h-32 { height: 8rem; }
.h-36 { height: 9rem; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.max-w-md {
  max-width: 28rem;
}

// 文本样式
.text-sm { 
  font-size: 0.875rem; 
  line-height: 1.25rem; 
}

.text-lg { 
  font-size: 1.125rem; 
  line-height: 1.75rem; 
}

.text-xl { 
  font-size: 1.25rem; 
  line-height: 1.75rem; 
}

.text-2xl { 
  font-size: 1.5rem; 
  line-height: 2rem; 
}

.text-3xl { 
  font-size: 1.875rem; 
  line-height: 2.25rem; 
}

.text-4xl { 
  font-size: 2.25rem; 
  line-height: 2.5rem; 
}

.text-5xl { 
  font-size: 3rem; 
  line-height: 1; 
}

.text-6xl { 
  font-size: 3.75rem; 
  line-height: 1; 
}

.font-bold { 
  font-weight: 700; 
}

.font-medium { 
  font-weight: 500; 
}

.text-white { 
  color: white; 
}

.text-gray-700 { 
  color: #374151; 
}

.text-shadow {
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

// 颜色类
.bg-white { 
  background-color: white; 
}

.bg-primary { 
  background-color: @primary; 
}

.bg-secondary1 { 
  background-color: @secondary1; 
}

.bg-secondary2 { 
  background-color: @secondary2; 
}

.bg-light { 
  background-color: @light; 
}

.bg-kb1 { 
  background-color: @kb1; 
}

.bg-kb2 { 
  background-color: @kb2; 
}

.bg-kb3 { 
  background-color: @kb3; 
}

.bg-kb4 { 
  background-color: @kb4; 
}

.bg-success { 
  background-color: @success; 
}

.bg-error { 
  background-color: @error; 
}

.bg-game { 
  background-color: @game; 
}

.text-primary { 
  color: @primary; 
}

.text-darkText { 
  color: @darkText; 
}

.text-kb1 { 
  color: @kb1; 
}

.text-kb2 { 
  color: @kb2; 
}

.text-kb3 { 
  color: @kb3; 
}

.text-kb4 { 
  color: @kb4; 
}

.text-success { 
  color: @success; 
}

.text-error { 
  color: @error; 
}

.text-game { 
  color: @game; 
}

// 透明度
.text-darkText-80 {
  color: fade(@darkText, 80%);
}

.text-darkText-70 {
  color: fade(@darkText, 70%);
}

// 边框和圆角
.rounded-full { 
  border-radius: 9999px; 
}

.rounded-lg { 
  border-radius: 0.5rem; 
}

.rounded-xl { 
  border-radius: 0.75rem; 
}

.rounded-2xl { 
  border-radius: 1rem; 
}

.border-3 { 
  border-width: 3px; 
}

.border-4 { 
  border-width: 4px; 
}

.border-primary { 
  border-color: @primary; 
}

.border-success { 
  border-color: @success; 
}

.border-error { 
  border-color: @error; 
}

// 阴影
.shadow-md {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.shadow-xl {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

// 网格布局
.grid { 
  display: grid; 
}

.grid-cols-3 { 
  grid-template-columns: repeat(3, minmax(0, 1fr)); 
}

.gap-3 { 
  gap: 0.75rem; 
}

// 溢出和定位
.overflow-hidden { 
  overflow: hidden; 
}

.overflow-x-hidden { 
  overflow-x: hidden; 
}

.overflow-y-auto { 
  overflow-y: auto; 
}

.top-5 { 
  top: 6.25rem; 
}

.top-20 { 
  top: 7rem; 
}

.top-40 { 
  top: 14rem; 
}

.bottom-10 { 
  bottom: 2.5rem; 
}

.left-10 { 
  left: 2.5rem; 
}

.left-1-4 { 
  left: 25%; 
}

.right-8 { 
  right: 2rem; 
}

.right-10 { 
  right: 2.5rem; 
}

.z-0 { 
  z-index: 0; 
}

.z-10 { 
  z-index: 10; 
}

.z-100 { 
  z-index: 100; 
}

// 其他工具类
.cursor-pointer { 
  cursor: pointer; 
}

.pointer-events-none { 
  pointer-events: none; 
}

.object-cover { 
  object-fit: contain; 
}

// 动画定义
@keyframes floating {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse {
  0%, 100% { 
    transform: scale(1); 
    box-shadow: 0 4px 15px fade(@game, 40%); 
  }
  50% { 
    transform: scale(1.05); 
    box-shadow: 0 6px 20px fade(@game, 60%); 
  }
}

@keyframes fadeOut {
  from { 
    opacity: 1; 
    transform: scale(1); 
  }
  to { 
    opacity: 0; 
    transform: scale(0.8); 
    height: 0; 
    margin: 0; 
    padding: 0; 
    overflow: hidden; 
  }
}

@keyframes scaleIn {
  from { 
    opacity: 0; 
    transform: scale(0.9); 
  }
  to { 
    opacity: 1; 
    transform: scale(1); 
  }
}

@keyframes successPulse {
  0% { 
    transform: scale(1); 
    box-shadow: 0 0 0 0 fade(@success, 40%); 
  }
  70% { 
    transform: scale(1.05); 
    box-shadow: 0 0 0 10px fade(@success, 0); 
  }
  100% { 
    transform: scale(1); 
    box-shadow: 0 0 0 0 fade(@success, 0); 
  }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

@keyframes scorePopup {
  0% { 
    opacity: 0.8; 
    transform: translate(-50%, -50%) scale(1); 
  }
  50% { 
    opacity: 0.8; 
    transform: translate(-50%, -60%) scale(1.1); 
  }
  100% { 
    opacity: 0; 
    transform: translate(-50%, -80%) scale(0.9); 
  }
}

@keyframes confetti {
  0% { 
    transform: translateY(0) rotate(0deg); 
    opacity: 1; 
  }
  100% { 
    transform: translateY(100vh) rotate(720deg); 
    opacity: 0; 
  }
}

@keyframes pulse-red {
  0%, 100% { 
    transform: scale(1); 
    color: @error;
  }
  50% { 
    transform: scale(1.1); 
    color: darken(@error, 10%);
  }
}

// 动画类
.floating {
  animation: floating 3s ease-in-out infinite;
}

.pulse-game {
  animation: pulse 2s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}

.animate-pulse {
  animation: pulse-red 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.scale-in {
  animation: scaleIn 0.3s ease-out forwards;
}

.card-bounce {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-selected {
  border: 3px solid @primary !important;
  box-shadow: 0 0 15px fade(@primary, 40%) !important;
}

.card-success {
  animation: successPulse 0.5s ease-out forwards;
}

.card-error {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.card-matched {
  animation: fadeOut 0.5s ease-out forwards;
}

.score-popup {
  animation: scorePopup 1s ease-out forwards;
}

.confetti {
  animation: confetti 2s ease-out forwards;
}

// 游戏特定样式
.game-container {
  height: calc(100vh - 180px);
  overflow-y: auto;
  scrollbar-width: none;
  
  &::-webkit-scrollbar {
    display: none;
  }
  
  @media (max-width: 480px) {
    height: calc(100vh - 160px);
  }
}

.decor {
  pointer-events: none;
  z-index: 0;
}

.square-card {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  justify-content:center;
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  }
}

.feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 100;
  opacity: 0;
}

.score-feedback {
  color: #886600;
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
  background-color: rgba(255, 215, 0, 0.8);
}

.penalty-feedback {
  color: #ffffff;
  text-shadow: 0 0 5px fade(@error, 50%);
  background-color: fade(@error, 80%);
}

// 特殊效果
.glow {
  box-shadow: 0 0 10px fade(@primary, 50%);
}

.success-glow {
  box-shadow: 0 0 15px fade(@success, 60%);
}

.error-glow {
  box-shadow: 0 0 15px fade(@error, 60%);
}

// 响应式设计
@media (max-width: 480px) {
  .text-3xl {
    font-size: 1.75rem;
  }
  
  .text-2xl {
    font-size: 1.5rem;
  }
  
  .px-12 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

// Antd Mobile 组件样式覆盖
.adm-button {
  border: none;
  font-family: @font-family;
  font-weight: bold;
  
  &:hover {
    opacity: 0.9;
  }
}

.adm-card {
  border-radius: 0.75rem;
  //overflow: hidden;
}

.adm-card-header {
  padding: 0.75rem;
}

// 辅助类
.space-y-3 {
  > * + * {
    margin-top: 0.75rem;
  }
}

// 禁用状态
.disabled {
  opacity: 0.6;
  pointer-events: none;
}

// 文字省略
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}